home *** CD-ROM | disk | FTP | other *** search
/ Freelog 46 / Freelog046.iso / Alu / Celestia / Win32LoresTex / celestia-lores-win32-1.3.0.exe / {app} / shaders / rings_arb.vp < prev    next >
Text File  |  2003-02-17  |  2KB  |  57 lines

  1. !!ARBvp1.0
  2.  
  3. # Compute ring illumination.  Assumes rings made of spherical particles,
  4. # and no occlusion or shadowing between ring particles.  We also compute the
  5. # texture coordinates for the projected shadow of a planet.
  6.  
  7. ATTRIB iPos          = vertex.position;
  8. ATTRIB iTex0         = vertex.texcoord[0];
  9. PARAM  mvp[4]        = { state.matrix.mvp };
  10. PARAM  eyePos        = program.env[1];
  11. PARAM  lightDir      = program.env[0];
  12. PARAM  diffuse       = program.env[2];
  13. PARAM  ambient       = state.lightmodel.ambient;
  14. PARAM  texgen_s      = program.env[10];
  15. PARAM  texgen_t      = program.env[11];
  16. PARAM  half          = 0.5;
  17. PARAM  one           = 1;
  18. OUTPUT oPos          = result.position;
  19. OUTPUT oColor        = result.color;
  20. OUTPUT oTex0         = result.texcoord[0];
  21. OUTPUT oTex1         = result.texcoord[1];
  22.  
  23. TEMP   illum;
  24. TEMP   eyeVec;
  25.  
  26. # Transform the vertex by the modelview matrix
  27. DP4   oPos.x, mvp[0], iPos;
  28. DP4   oPos.y, mvp[1], iPos;
  29. DP4   oPos.z, mvp[2], iPos;
  30. DP4   oPos.w, mvp[3], iPos;
  31.  
  32. # Get the vector from the eye to the vertex
  33. SUB   eyeVec, eyePos, iPos;
  34.  
  35. # Normalize it
  36. DP3   eyeVec.w, eyeVec, eyeVec;
  37. RSQ   eyeVec.w, eyeVec.w;
  38. MUL   eyeVec, eyeVec, eyeVec.w;
  39.  
  40. # Compute the illumination
  41. DP3   illum.x, eyeVec, lightDir;
  42. ADD   illum.x, illum.x, one;
  43. MUL   illum.x, illum.x, half;
  44.  
  45. # Output the texture
  46. MOV   oTex0, iTex0;
  47.  
  48. # The second texture is the shadow; we need to compute the
  49. # it from the vertex coordinate.
  50. DP4   oTex1.x, texgen_s, iPos;
  51. DP4   oTex1.y, texgen_t, iPos;
  52.  
  53. # Output the primary color
  54. MAD   oColor, diffuse, illum.x, ambient;
  55.  
  56. END
  57.